package com.ll.menu.user.app.entity.response;

import java.io.Serializable;

/**
 * BaseData
 *
 * @author wangheng
 */
public class BaseResponse implements Serializable {

    private static final long serialVersionUID = -7083881313754553830L;

    // 请求成功的state值
    private static final int CODE_SUCCESS = 0;
    private static final int CODE_TOKEN_TIMEOUT = 4001;
    private static final int CODE_UNKNOWN_ERROR = 5001;
    private static final int CODE_USER_DELETED = -3;

    private int code = -1;
    private String message;
    private long serverTime;


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        if(code == CODE_TOKEN_TIMEOUT){
            return null;
        }
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }



    /**
     * 是否请求成功
     *
     * @return 是否请求成功
     */
    public boolean isRequestSuccess() {
        return CODE_SUCCESS == code;
    }

    public boolean isTokenTimeout(){
        return code == CODE_TOKEN_TIMEOUT;
    }

    public boolean isUserDeleted(){
        return code == CODE_USER_DELETED;
    }

    public boolean isUnknownError(){
        return code == CODE_UNKNOWN_ERROR;
    }

    public long getServerTime() {
        return serverTime;
    }

    public void setServerTime(long serverTime) {
        this.serverTime = serverTime;
    }
}
